// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2

package svc

import (
	"nexus/addon"
	"nexus/internal/config"
	"nexus/internal/middleware"
	"nexus/model"

	"nexus/utils"

	"github.com/zeromicro/go-zero/rest"
)

type ServiceContext struct {
	Config          config.Config
	TokenMiddleware rest.Middleware
	NexusDB         *model.NexusDB
	JWT             *utils.JWT
	Redis           *addon.RedisAddons
}

func NewServiceContext(c config.Config) *ServiceContext {

	logger := utils.NewLogger(c)
	db := model.NewNexusDB(c, logger)
	jwt := utils.NewJWT(c)
	redis := addon.NewRedis(c)

	return &ServiceContext{
		Config:          c,
		TokenMiddleware: middleware.NewTokenMiddleware(jwt, redis).Handle,
		NexusDB:         db,
		JWT:             jwt,
		Redis:           redis,
	}
}
